<script setup>

import {useStore} from 'vuex'
import { computed } from "vue-demi";
import {useRouter} from "vue-router";

let store = useStore();
let handleCollapse =() => {
  store.commit("updateIsCollapse")
}

const current = computed(() => {
  return store.state.currentMenu
})

const router = useRouter();
const handleLogout = ()=>{
  store.commit("cleanMenu")
  router.push("login")
}

</script>

<template>
  <el-header>
    <div class="left">
      <el-button size="small" @click="handleCollapse">
        <el-icon :size="20">
          <Menu/>
        </el-icon>
      </el-button>
      <el-breadcrumb separator="/" class="bread">
        <!-- 首页是一定存在的所以直接写死 -->
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>

        <el-breadcrumb-item :to="current.path" v-if="current">{{
            current.label
          }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img class="user" src="../assets/images/user.png" alt="">
        </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item @click="handleLogout">退出</el-dropdown-item>
            </el-dropdown-menu>
          </template>
      </el-dropdown>
    </div>
  </el-header>
</template>

<style lang="less" scoped>
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #333;
}
.left {
    display: flex;
    align-items: center;
    .el-button {
      margin-right: 20px;
    }
    h3 {
      color: #fff;
    }
  }


  .right {
    .user {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }

 //.bread /deep/ span {
 //  color: #fff !important;
 //  cursor: pointer !important;
 //}

:deep(.bread span) {
  color: #fff !important;
  cursor: pointer !important;
}

</style>
